<template>
    <div>
        <h2>登录</h2>
        <table class="table">
            <tbody>
                <tr>
                    <td>账号</td>
                    <td>
                        <input v-model="data.name" type="text">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input v-model="data.password" type="password">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" class="btn btn-success" @click="deng">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { useCounterStore } from '@/stores/counter';
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
var use=useCounterStore();
const router=useRouter();
const data=ref({
    name:'',
    password:''
})
const deng=()=>{
    axios.get('https://localhost:7260/api/Member/DengLu',{params:data.value}).then(res=>{
        if(res.data.id==-1){
            alert('账号错误')
        }
        if(res.data.id==-2){
            alert('密码错误');
        }
        if(res.data.id>0){
            alert('登陆成功');
            use.userlogin.islogin=true;
            
            router.push('/addbf')
        }
    })
}
</script>

<style scoped>

</style>